package kr.hkit.powerjava.chapter22.work;

public class Student implements Comparable<Student>{

	private int stdNum;
	private String stdName;
	private int korScore;
	private int engScore;
	private int mathScore;

	public Student(int stdNum, String stdName) {
		this.stdNum = stdNum;
		this.stdName = stdName;
	}

	public Student(int stdNum, String stdName, int korScore, int engScore,
			int mathScore) {
		this.stdNum = stdNum;
		this.stdName = stdName;
		this.korScore = korScore;
		this.engScore = engScore;
		this.mathScore = mathScore;
	}

	public int getKorScore() {
		return korScore;
	}

	public void setKorScore(int korScore) {
		this.korScore = korScore;
	}

	public int getEngScore() {
		return engScore;
	}

	public void setEngScore(int engScore) {
		this.engScore = engScore;
	}

	public int getMathScore() {
		return mathScore;
	}

	public void setMathScore(int mathScore) {
		this.mathScore = mathScore;
	}

	public int getStdNum() {
		return stdNum;
	}

	public void setStdNum(int stdNum) {
		this.stdNum = stdNum;
	}

	public String getStdName() {
		return stdName;
	}

	public void setStdName(String stdName) {
		this.stdName = stdName;
	}

	public int totalScore() {
		return korScore + engScore + mathScore;
	}

	public double totalAvg() {
		return totalScore() / 3.0;
	}

	@Override
	public String toString() {
		return String.format("%3s\t%5s\t%3d\t%3d\t%3d\t%4s\t%5.2f", stdNum,
				stdName, korScore, engScore, mathScore, totalScore(),
				totalAvg());
	}

	@Override
	public boolean equals(Object obj) {
		return stdNum == ((Student) obj).stdNum
				&& stdName.equals(((Student) obj).stdName);
	}

	@Override
	public int compareTo(Student o) {
		return totalScore() - o.totalScore();
	}

}
